package net.loyintean.pearlshell.validation.rule;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import net.loyintean.pearlshell.validation.IValidRule;
import net.loyintean.pearlshell.validation.IValidRuleConfig;

class StringPhoneNumValidRuleImpl extends AbstractStringValidRuleImpl implements
		IValidRule {
	StringPhoneNumValidRuleImpl() {
		super();
	}

	/** PhoneNum :只要求1开头的11位数字 */
	private static final Pattern PhoneNum = Pattern.compile("^1\\d{10}$");

	@Override
	public String errorMsg(IValidRuleConfig config) {
		return "不符合手机号码的格式";
	}

	@Override
	protected boolean validString(String toValid, IValidRuleConfig config) {
		Matcher phone_num = PhoneNum.matcher(toValid);
		return phone_num.find();
	}

}
